<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    protected $fillable=[
        'order_num','status','address_id','user_id','totalprice'
    ];

//    订单表和订单明细表之间的模型关联方法
    public function detail(){
        return $this->hasMany(OrderDetail::class,'order_num','order_num');
    }
    //写一个订单到地址的模型关联方法
    public function address(){
        return $this->belongsTo(Address::class);
    }
}
